const openHref = (href) => {
  /**
   * QC647671
   * window.em.openLink 函数在企业微信下无法使用，因此需要添加判断，使企业微信下打开链接时使用window.open
   * shipf 201907291454
   */
  if (window.em && (typeof window.em.checkJsApi === 'function') && window.em.checkJsApi('openLink')) {
    window.em.openLink({
      url: href,
      openType: 2
    });
  } else {
    window.open(href);
  }
}
// TODO 确认各个应用的跳转链接
// 打开应用连接
export const openAppLink = (obj, linkid, linkType) => {
  // 新地址
  if (Number(linkType) === 37) {
    window.openFullWindowHaveBar
      ? window.openFullWindowHaveBar(
      `/spa/document/index.jsp?id=${linkid}&router=1#/main/document/detail`
      )
      : openHref(
      `/spa/document/static4mobile/index.html#/doc/${linkid}`
      );
  } else { //文档
    if (linkType === "37"){
      window.openFullWindowHaveBar
      ? window.openFullWindowHaveBar(
        `/spa/document/index.jsp?id=${linkid}&router=1#/main/document/detail`
        )
        : openHref(
        `/spa/document/static4mobile/index.html#/doc/${linkid}`
        );
    }
    else if (linkType === "task"){ //
       openHref(
          "/proj/process/ViewTask.jsp?moduleid=blog&taskrecordid=" +
          linkid +
          "&linkType=" +
          linkType +
          "&linkid=" +
          linkid
        )
    }
      
    else if (linkType === "18") {
      //客户
      window.openFullWindowHaveBar
      ? window.openFullWindowHaveBar(
          "/spa/crm/static/index.html#/main/crm/customerView?customerId=" +
          linkid+
          "&linkType=" +
          linkType +
          "&linkid=" +
          linkid
        )
        : openHref(
        `/spa/crm/static4mobile/index.html#/customerCard/${linkid}`
        );
    }
    else if (linkType === "152"){
     //流程
      openHref(
        "/spa/workflow/static4mobileform/index.html#/req?requestid=" +
        linkid +
        "&linkType=" +
        linkType +
        "&linkid=" +
        linkid
      );
    }
    else if (linkType === "135"){ //项目
      window.openFullWindowHaveBar
      ? window.openFullWindowHaveBar(
          "/spa/prj/index.html#/main/prj/projectCard?prjid=" +
          linkid+
          "&linkType=" +
          linkType +
          "&linkid=" +
          linkid
        )
        : openHref(
        `/spa/prj/static4mobile/index.html#/ProjectDetails/0/${linkid}`
        );
    }
    else if (linkType === "prjtsk"){//任务
      window.openFullWindowHaveBar
      ? window.openFullWindowHaveBar(
          "/spa/prj/index.html#/main/prj/taskCard?taskid=" +
          linkid+
          "&linkType=" +
          linkType +
          "&linkid=" +
          linkid
        )
        : openHref(
        `/spa/prj/static4mobile/index.html#/TaskDetails/0/${linkid}`
        );
    }
    else if(linkType=="workplan"){
      window.openFullWindowHaveBar
      ? window.openFullWindowHaveBar(
          "/spa/prj/index.html#/main/prj/taskCard?taskid=" +
          linkid+
          "&linkType=" +
          linkType +
          "&linkid=" +
          linkid
        )
        : openHref(
        `/spa/prj/static4mobile/index.html#/TaskDetails/0/${linkid}`
        );
    }
        
  }
  return false;
};
